package com.gaussian.property.module.biz.enums;

/**
 * @description:
 * @author: songqi(13776346982)
 * @date: 2024/4/10 09:23
 */
public enum Period{

    daily("daily", "每天"),
    weekly("weekly", "每周"),
    monthly("monthly", "每月");


    private final String name;
    private final String desc;

    Period(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    // 根据name返回枚举对象
    public static Period getPeriodByName(String name) {
        for (Period item : Period.values()) {
            if (item.getName().equals(name)) {
                return item;
            }
        }
        return null;
    }

    // 根据name返回desc
    public static String getDescByName(String name) {
        Period period = getPeriodByName(name);
        if (period != null) {
            return period.getDesc();
        }
        return null;
    }
}
